import { createApp } from 'vue'
import App from './App.vue'

import '@/style/reset.scss'
import '@/style/base.scss'

import router from './router'

// 引入懒加载插件
import {lazyPlugin} from '@/directives'


// 引入全局组件
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import GoodsItem from '@/components/GoodsItem.vue'
import BackTop from '@/components/BackTop.vue'
import Numbox from '@/components/Numbox.vue'
import Carousel from '@/components/Carousel.vue'
import Empty from '@/components/Empty.vue'
import TridentCheckbox from '@/components/TridentCheckbox.vue'
import GuessLike from '@/components/GuessLike.vue'
import GoodsItemSkeleton from '@/components/GoodsItemSkeleton.vue'

// 导入 pinia 实例
import pinia from "./stores"

// 引入全局守卫文件
import './guard'

// 引入ElementPlus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

const app = createApp(App)

// 注册全局组件
app.component('Header', Header)
app.component('Footer', Footer)
app.component('GoodsItem', GoodsItem)
app.component('BackTop', BackTop)
app.component('Numbox', Numbox)
app.component('Carousel', Carousel)
app.component('Empty', Empty)
app.component('TridentCheckbox', TridentCheckbox)
app.component('GuessLike', GuessLike)
app.component('GoodsItemSkeleton', GoodsItemSkeleton)

// 配置全局变量 页面中使用 inject 接收
app.provide('global',{
    FILE_DOMAIN: import.meta.env.VITE_MINIO_FILE_DOMAIN,
    FILE_SERVER: import.meta.env.VITE_FILE_SERVER,
    CID: 2349
})


// 使用pinia
app.use(pinia)

// 使用图片懒加载插件
app.use(lazyPlugin)

// 使用路由
app.use(router)

app.use(ElementPlus, {
    locale: zhCn,
})

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.mount('#app')
